//-----------------------------------------------------------------------
// <copyright file="a_CatMainDAO.cs" company="AACECOM">
//     Copyright (c) AACECOM. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Data;
using ThoiTrang.Entities;
using Microsoft.Practices.EnterpriseLibrary.Data;
using ThoiTrang.Entities;
using System.Data.Common;

namespace ThoiTrang.Data
{	
	public class a_CatMainDAO : a_CatMainDAOBase
	{
		public a_CatMainDAO()
		{
		}

        public virtual a_CatMainCollection Geta_CatMainListByGroup(int GroupId)
        {            
            try
            {
                Database database = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = database.GetStoredProcCommand("a_CatMain_selListByGroup");

                database.AddInParameter(dbCommand, "@GroupId", DbType.Int32, GroupId);
                
                a_CatMainCollection a_CatMainCollection = new a_CatMainCollection();
                using (IDataReader reader = database.ExecuteReader(dbCommand))
                {
                    while (reader.Read())
                    {
                        a_CatMain a_CatMain = Createa_CatMainFromReader(reader);
                        a_CatMainCollection.Add(a_CatMain);
                    }
                    reader.Close();
                }
                return a_CatMainCollection;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
	}
}
